package util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test1 {

    public static void main(String args[]) {
//        {
//            "code": 200,
//                "message": "成功",
//                "status": true,
//                "data": {
//                    "date": "报告日期:2021年09月17日",
//                    "contractName": "杭州合同报告:",
//                    "risk":[
//                            {
//                                "疑似开户行账号使用风险":{
//                                "合同汇总金额（含税）":9.403003600000001E7,
//                                "合同份数":1478
//                                }
//                            },{
//                                "疑似拆分合同":{
//                                    "合同汇总金额（含税）":2.2936931099999988E8,
//                                    "合同份数":6283
//                                }
//                            }
//                        ]
//                }
//        }

//        StringBuffer sb = new StringBuffer();
//        BufferedReader ready;
//        try {
//            ready = new BufferedReader(new InputStreamReader(new FileInputStream(new File("E:\\mht文件转换\\test.mht")), "UTF-8"));
//            String temp = "";
//            while (null != (temp = ready.readLine())) {
//                sb.append(temp);
////                System.out.println(temp);
//            }
//            System.out.println(sb.toString());
//        } catch (Exception e) {
//// TODO Auto-generated catch block
//            e.printStackTrace();
//        }
//        File file = new File("C:\\Users\\小胖子\\Downloads\\浙江省合同风险统计报告.docx");
//        String str = file.getName().substring(file.getName().lastIndexOf("."),file.getName().length());
//        System.out.println(str);

        String signingInstructions = "本合同系我公司与杭州和达市政园林建设有限公司签订的【11号泵站机房电费结算协议】的补充协议，" +
                "原合同电费单价0.7元/度，结算依据为发票复印件。" +
                "现签订补充协议，调整为电费单价0.75元/度（含税13%），" +
                "结算依据为增值税专用发票。本合同的项目编号为21WL003C，" +
                "合同根据站点需求签订，合同文本采用双方协商文本，" +
                "自合同签署起至2020年12月31日止。";

        String feesAa = null;
        String feesBb = null;
        String signStrA = null;
//        if (signingInstructions != null && !"".equals(signingInstructions) && (signingInstructions.lastIndexOf("电费单价") > 0)){
//            signStrA = signingInstructions.substring(0,signingInstructions.lastIndexOf("电费单价"));
//        }

        if(signingInstructions.lastIndexOf("电费单价") > 0 ){
            if(signingInstructions.indexOf("元",signingInstructions.lastIndexOf("电费单价")) > 0){
                String a = signingInstructions.substring(signingInstructions.lastIndexOf("电费单价")+4, signingInstructions.indexOf("元",signingInstructions.lastIndexOf("电费单价")));
                if(a.indexOf("：") >= 0){
                    feesAa = a.substring(a.indexOf("：")+1).replace("【","").replace("】","");
                }else if(a.indexOf("至") >= 0){
                    feesAa = a.substring(a.indexOf("至")+1).replace("【","").replace("】","");
                }else{
                    feesAa = a.substring(a.indexOf("为")+1).replace("【","").replace("】","");
                }
            }
        }

        if(signingInstructions.lastIndexOf("电费单价",signingInstructions.lastIndexOf("电费单价")-1) > 0 ){
            if(signingInstructions.indexOf("元",signingInstructions.lastIndexOf("电费单价",signingInstructions.lastIndexOf("电费单价")-1)) > 0){
                String b = signingInstructions.substring(signingInstructions.lastIndexOf("电费单价",signingInstructions.lastIndexOf("电费单价")-1)+4,  signingInstructions.indexOf("元",signingInstructions.lastIndexOf("电费单价",signingInstructions.lastIndexOf("电费单价")-1)));
                if(b.indexOf("：") >= 0){
                    feesBb = b.substring(b.indexOf("：")+1).replace("【","").replace("】","");
                }else if(b.indexOf("至") >= 0){
                    feesBb = b.substring(b.indexOf("至")+1).replace("【","").replace("】","");
                }else{
                    feesBb = b.substring(b.indexOf("为")+1).replace("【","").replace("】","");
                }
            }
        }

        double feesa =Double.valueOf(feesAa.replaceAll(" ", "").replaceAll(" ", "")).doubleValue();
        double feesb =Double.valueOf(feesBb.replaceAll(" ", "").replaceAll(" ", "")).doubleValue();

        System.out.println(feesAa);
        System.out.println(feesBb);
    }
}
